<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>node</title>
    <link rel="stylesheet" href="/public/main.css">
    <script src="/public/js/jq3.0.0.min.js"></script>
    <script src="/public/js/axios.min.js"></script>
    <script src="/public/js/public.js"></script>
</head>
<body>
    <div class="main">


        <div class="blog-navigate">
            <div class="blog-container clear">
                <div class="row-item-s">
                    <span class="user-info" id="userName">
                        用户名：{{userinfo.username}}
                    </span>
                    <span class="user-info" id="userId">
                        用户id：{{userinfo._id}}
                    </span>
                    {% if userinfo.isAdmin %}
                    <span class="user-info">
                        权限：管理员用户
                    </span>
                    <div class="user-info-btn user-info">
                        <a href="/admin" class="btn-x">进入后台</a>
                    </div>

                    {% else %}
                    <span class="user-info">
                        权限：普通用户
                    </span>
                    {% endif %}
                    <div class="user-info-btn">
                        <input type="button" class="btn-x" value="退出" id="login_out">
                    </div>
                </div>
            </div>
        </div>


        <div class="blog-container">
            <div class="blog-header-box">
                {%if !category%}
                <a class="blog-header-item active" href="/">
                    首页
                </a>
                {%else%}
                <a class="blog-header-item" href="/">
                    首页
                </a>
                {%endif%}
                {% for item in typelist %}
                    {%if category===item._id.toString()%}
                    <a class="blog-header-item active" href="/?category={{item._id.toString()}}">
                        {{item.name.toString()}}
                    </a>
                    {%else%}
                    <a class="blog-header-item" href="/?category={{item._id.toString()}}">
                        {{item.name.toString()}}
                    </a>
                    {%endif%}
                {% endfor %}
            </div>


            <h3>Express.JS</h3>
            {% if userinfo._id %}
            <div>条目数：{{count}}</div>
            <div>当前页：{{page}}</div>
            <div>总页数：{{pages}}</div>
            <div class="blog-content">
                {%for ele in content%}
                <div class="blog-content-grp" id="{{ele._id.toString()}}">
                    <div class="blog-content-h">
                        {{ele.title}}
                    </div>
                    <span>简介：{{ele.distribution}}</span><span>作者：{{ele.user.username}}</span><span>时间：{{ele.addTime|date('Y年m月d日 h:i:s',-8*60)}}</span>
                    <div>分类：{{ele.category.name}}</div>
                    <div class="blog-content-txt">内容：{{ele.content}}</div>
                    <div>阅读量：{{ele.views}}</div>
                    <div><a href="/view?contentid={{ele._id.toString()}}">阅读全文</a></div>
                </div>
                {%endfor%}
            </div>
            <div class="page-tem">
                {%if page<=1 %}
                <a href="javascript:void(0)">没有上一页了</a>
                {%else%}
                <a href="/?category={{category}}&page={{page - 1}}">prev</a>
                {%endif%}

                总条数：{{count}}
                总页数：{{pages}}
                每页显示：{{limit}}
                当前页：{{page}}

                {%if page==pages %}
                <a href="javascript:void(0)">没有下一页了</a>
                {%else%}
                <a href="/?category={{category}}&page={{page + 1}}">next</a>
                {%endif%}
            </div>
            {% else %}
            <div class="login-content">
                <div class="login-input">
                    <input type="text" id="account" placeholder="name" name="account">
                    <input type="password" id="password" placeholder="password" name="password">
                    <input type="password" id="repassword" placeholder="repassword" name="repassword">
                </div>
                <div class="btn-box clear">
                    <div class="box-f-x">
                        <input class="btn-x" type="submit" value="注册" id="zc">
                    </div>
                    <div class="box-f-x">
                        <input class="btn-x" type="submit" value="登录" id="dl">
                    </div>
                </div>
            </div>

            <div>条目数：{{count}}</div>
            <div>当前页：{{page}}</div>
            <div>总页数：{{pages}}</div>
            <div class="blog-content">
                {%for ele in content%}
                <div class="blog-content-grp" id="{{ele._id.toString()}}">
                    <div class="blog-content-h">
                        {{ele.title}}
                    </div>
                    <span>简介：{{ele.distribution}}</span><span>作者：{{ele.user.username}}</span><span>时间：{{ele.addTime|date('Y年m月d日 h:i:s',-8*60)}}</span>
                    <div>分类：{{ele.category.name}}</div>
                    <div class="blog-content-txt">内容：{{ele.content}}</div>
                    <div>阅读量：{{ele.views}}</div>
                    <div><a href="/view?contentid={{ele._id.toString()}}">阅读全文</a></div>
                </div>
                {%endfor%}
            </div>
            <div class="page-tem">
                {%if page<=1 %}
                <a href="javascript:void(0)">没有上一页了</a>
                {%else%}
                <a href="/?category={{category}}&page={{page - 1}}">prev</a>
                {%endif%}

                总条数：{{count}}
                总页数：{{pages}}
                每页显示：{{limit}}
                当前页：{{page}}

                {%if page==pages %}
                <a href="javascript:void(0)">没有下一页了</a>
                {%else%}
                <a href="/?category={{category}}&page={{page + 1}}">next</a>
                {%endif%}
            </div>

            {% endif %}




        </div>
    </div>
</body>
</html>
